﻿/// <reference path="../../../extjs/ext-all-debug.js" />
Ext.define('yzmh.view.download.List', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.downloadlist',
    closable: true,
    title: '',
    store: 'Downloads',
    loadMask: true,
    columnLines: true,
    forceFit: true,
    sortableColumns: false,
    viewConfig: {
        trackOver: false,
        stripeRows: true
    },

    tbar: [{
        xtype: 'combo',
        name: 'server',
        fieldLabel: '源服务器',
        typeAhead: true,
        displayField: 'name',
        valueField: 'value',
        store: Ext.create("Ext.data.ArrayStore", {
            fields: ['name', 'value'],
            data: [
                ['新动漫默认', "http://mh2.xindm.cn/"],
                ['新动漫加速1', "http://mh.xindm.cn/"],
                ['天上人间江苏电信', "http://58.218.39.221:82/"],
                ['天上人间浙江电信1', "http://61.164.109.41:82/"], 
                ['天上人间浙江电信2', "http://61.164.108.102:82/"],
                ['天上人间山西网通', "http://218.26.223.197:82/"],
                ['漫画猪智能', "http://imgs.manhuazhu.com/"],
                ['漫画猪电信', "http://imgs2.manhuazhu.com/"],
                ['漫画猪网通', "http://imgs1.manhuazhu.com/"],
                ['精明眼电信', "http://mh.jmmh.net:2011/"], ['精明眼网通', "http://lt.jmydm.jmmh.net:2011/"]
            ]
        }),
        labelWidth: 60,
        labelAlign: 'right',
        width: 200,
        forceSelection: true,
        editable: false,
        queryMode: 'local',
        listeners: {
            afterrender: function () {
                this.setValue(this.getStore().getAt(0).get("value"));
            }
        }
    }, {
        xtype: 'combo',
        name: 'comicdata',
        fieldLabel: '下载至',
        typeAhead: true,
        displayField: 'name',
        valueField: 'value',
        store: 'ComicDatas',
        labelWidth: 60,
        labelAlign: 'right',
        width: 250,
        forceSelection: true,
        editable: false,
        queryMode: 'local',
        listConfig: {
            tpl: [
               "<ul><tpl for=\".\">",
               "<li role=\"option\" class=\"x-boundlist-item\">{name}[{value}]</li>",
               "</tpl></ul>"
            ]
        },
        listeners: {
            afterrender: function () {
                this.setValue(this.getStore().getAt(0).get("value"));
            }
        }
    }, {
        xtype: 'combo',
        name: 'proxy',
        fieldLabel: '代理',
        typeAhead: true,
        store: new Ext.data.JsonStore({
            fields: ['name', 'value'],
            proxy: {
                type: 'ajax',
                url: 'data/download.aspx?a=proxylist',
                reader: {
                    type: 'json'
                }
            }
        }),
        displayField: 'name',
        valueField: 'value',
        labelWidth: 60,
        labelAlign: 'right',
        width: 300,
        forceSelection: true,
        editable: false,
        queryMode: 'remote'
    },
        { xtype: 'tbfill' }, { action: 'editmulti', text: '批量修改', icon: 'extjs/icons/book_edit.png' }, "-", { action: 'downloadtest', text: '测试', icon: 'extjs/icons/picture_save.png' }, "-", { action: 'download', text: '下载', icon: 'extjs/icons/picture_save.png' }, "-", { action: 'complete', text: '完成', icon: 'extjs/icons/picture_go.png' }
    ],
    selType: 'rowmodel',
    selModel: Ext.create("Ext.selection.RowModel", {
        mode: 'MULTI'
    }),
    features: [Ext.create('Ext.grid.feature.Grouping', {
        groupHeaderTpl: '{[values.rows[0].data.mhmc]} [{[values.rows[0].data.zzmc]}] ({rows.length} 个章节)',
        hideGroupedHeader: true,
        startCollapsed: false,
        id: 'downloadGrouping'
    })],
    columns: [
        { header: '编号', dataIndex: 'id', align: 'center', width: 35 },
        {
            header: '名称', dataIndex: 'zjmc', width: 80
        },
        
        { header: '更新时间', dataIndex: 'time', align: 'center', renderer: Ext.util.Format.dateRenderer('Y-m-d h:i') },
        { header: '图片路径', dataIndex: 'tpadd', flex: 0, width: 120 },
        { header: '图片地址', dataIndex: 'tpurl', width: 80 },
        { header: '数量', dataIndex: 'tps', align: 'center', width: 50 },
        { header: '存在', dataIndex: 'exist', align: 'center', width: 50 },
        {
            xtype: 'dvp_progresscolumn',
            width: 110,
            dataIndex: 'existper'
        }, {
            header: '状态',
            width: 50,
            dataIndex: 'status'
        }, {
            action: 'edit',
            xtype: 'actioncolumn',
            width: 40,
            header: '编辑',
            align: 'center',
            icon: 'extjs/icons/book_edit.png'
        }, {
            action: 'view',
            xtype: 'actioncolumn',
            width: 40,
            header: '预览',
            align: 'center',
            icon: 'extjs/icons/page_link.png'
        }
    ],
    bbar: {
        xtype:'pagingtoolbar',
        store:  'Downloads',
        displayInfo: true,
        displayMsg: '显示数据 {0} - {1} of {2}',
        emptyMsg: "没有查询到数据"
    }
});


